package be.obia.moo.dovebird.MCP;

import java.util.Random;

import be.obia.moo.dovebird.MainActivity;
import be.obia.moo.dovebird.TCPLine;

public class Handler {
	public String authKey = "0-0-0";
	MainActivity activity;

	public Handler(MainActivity act) {
		authKey = String.valueOf((new Random().nextInt(89999) + 10000));
		activity = act;
	}
	
	public void Handle(TCPLine line) {
		String[] parts = line.Line.split(" ");
		String pkg = parts[0].substring(3);
		if(pkg.equals("mcp")) {
			line.Client.sendData("#$#mcp authentication-key: " + authKey + " version: 2.1 to: 2.1");
			line.Client.sendData("#$#mcp-negotiate-can " + authKey + " package: dns-com-vmoo-client min-version: 1.0 max-version: 1.1");
			line.Client.sendData("#$#mcp-negotiate-end");
			line.Client.sendData("#$#dns-com-vmoo-client-info " + authKey + " name: \"doveBird\" text-version: \"" + activity.RenderMode + "-" + activity.versionName + "\" internal-version: \"" + activity.versionCode + "\" reg-id: 0 flags: m");
		}
	}
}
